local cjson = require "cjson"
local auth = require "auth"

ngx.req.read_body()
local body = ngx.req.get_body_data()
local data = cjson.decode(body)

local success, message = auth.register(data.username, data.password)

if success then
    ngx.say(cjson.encode({success = true, message = message}))
else
    ngx.status = 400
    ngx.say(cjson.encode({success = false, message = message}))
end
